package com.example.houtai.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.houtai.entity.SysUser;
import com.example.houtai.entity.SysUserRole;
import com.example.houtai.service.ISysUserRoleService;
import com.org.dto.SysUserRoleDto;
import com.org.dto.UserDto;
import com.org.vo.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 用户与角色对应关系 前端控制器
 * </p>
 *
 * @author 龚梦
 * @since 2021-03-22
 */
@RestController
@RequestMapping("/sys/userrole")
public class SysUserRoleController {

    @Autowired
    private ISysUserRoleService userRoleService;


    @RequestMapping("seluserrolebyuid")
    public ResultEntity seluserrolebyuid(@RequestBody UserDto userDto){
        SysUserRole sysUserRole=new SysUserRole();
        sysUserRole.setUserId(userDto.getUserId());
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",sysUserRole.getUserId());

        List<SysUserRoleDto> list=userRoleService.listbyuserid(userDto.getUserId());

      /*  List list = userRoleService.list(queryWrapper);
        for (Object o : list) {
            System.out.println(o);
        }
*/
        return ResultEntity.ok("200",list);
    }

}
